package com.oig.sys.workflow.dao;

import com.oig.sys.workflow.entity.TbListenerEvent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author wuxl
 */
public interface ITbListenerEventDao extends JpaRepository<TbListenerEvent, Integer> {

	@Query("from TbListenerEvent a where a.id=:id")
	TbListenerEvent getLEById(@Param("id") Integer id);

	List<TbListenerEvent> findAllByObjectId(Integer objectId);

	@Query("select a.id from TbListenerEvent a where a.objectId=:objectId")
	List<Integer> findAllIdByObjectId(@Param("objectId") Integer objectId);

	@Query("select a.id from TbListenerEvent a where a.objectId=:objectId and a.id not in(:idList)")
	List<Integer> findAllDelId(@Param("objectId") Integer objectId, @Param("idList") List<Integer> idList);

	@Modifying
	@Query("delete from TbListenerEvent a where a.id in(:idList)")
	void deleteByIdList(@Param("idList") List<Integer> idList);
}
